<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="/layui/css/layui.css">
    <script type="text/javascript" src="/js/libs/jquery-2.1.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-select.min.css">
    <script src="/js/bootstrap/bootstrap.min.js"></script>
    <script src="/js/bootstrap/bootstrap-select.min.js"></script>
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-md-offset-2 col-lg-offset-2">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
            <div class='form-group'>
				<label class='col-md-4 control-label'>供应商名称</label>
				<div class='col-md-8'>
					<input class='form-control' placeholder='供应商名称' type='text' name='name' id='name' data-bv-notempty='true' data-bv-notempty-message='供应商名称 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-4 control-label'>联系人</label>
				<div class='col-md-8'>
					<input class='form-control' placeholder='联系人' type='text' name='contact' id='contact' data-bv-notempty='true' data-bv-notempty-message='联系人 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-4 control-label'>联系电话</label>
				<div class='col-md-8'>
					<input class='form-control' placeholder='联系电话' type='text' name='phone' id='phone' data-bv-notempty='true' data-bv-notempty-message='联系电话 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-4 control-label'>联系地址</label>
				<div class='col-md-8'>
					<input class='form-control' placeholder='联系地址' type='text' name='address' id='address' data-bv-notempty='true' data-bv-notempty-message='联系地址 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-4 control-label'>是否可用</label>
				<div class='col-md-8'>
					<select class="form-control input-sm selectpicker show-tick" name="usable" id="usable"
							title="是否可用" data-bv-notempty='true' data-live-search="true"></select>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-4 control-label'>备注</label>
				<div class='col-md-8'>
					<textarea class="form-control" placeholder="备注" name="remark" id="remark"></textarea>
				</div>
			</div>

			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <!--<button class="btn btn-primary" onclick="location.href='supplierList.html'">返回</button>-->
						<button class="btn btn-primary" type="submit" onclick="save()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>
		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="/js/jq.js"></script>
    <script type="text/javascript" src="/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
    <script type="text/javascript" src="/layui/layui.js"></script>
    <script type="text/javascript" src="/js/dict.js"></script>
    <script type="text/javascript" src="/js/libs/jquery.ztree.all-3.5.min.js"></script>
    <script type="text/javascript" src="/js/my/ztree-menu.js"></script>
	<script type="text/javascript">

        showDictSelect('usable', 'boolean', '', '1');

	    $(function () {
            $('#form').bootstrapValidator();
        });

		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		function save() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'post',
				url : '/supplier/',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("添加成功", {shift: -1, time: 1000}, function(){
                        parent.location.reload();//关闭iFrame
                    });
				}
			});
		}
		
	</script>
</body>
</html>
